package org.springframework.learn.beans;

import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.learn.beans.config.Person;
import org.springframework.learn.beans.data.AService;
import org.springframework.learn.beans.data.Car;
import org.springframework.learn.beans.note.fullConfig.FullConfig;
import org.springframework.learn.beans.service.OrderService;
import org.springframework.learn.beans.service.UserService;
import org.springframework.learn.beans.service.ZhouyuImport;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;


@Configuration
//@Import({ZhouyuImport.class})
//@ComponentScan(value = {"org.springframework.learn.beans.reference"})
//@EnableAspectJAutoProxy
//@ImportResource(value = {"classpath:beans.xml"})
//@EnableAsync
//@Import({UserService.class})
//@EnableTransactionManagement
//@EnableAspectJAutoProxy
@Import(Person.class)
public class BeanApplication implements BeanDefinitionRegistryPostProcessor {

	public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BeanApplication.class);
		// 销毁
//		context.close();

//		Object bean1 = context.getBean("&userFactoryBean");
//		Object bean2 = context.getBean("userFactoryBean");
//		System.out.println(bean1);
//		System.out.println(bean2);
//		context.close();
//		MyComponentScan.InnerClass bean = context.getBean(MyComponentScan.InnerClass.class);
//		System.out.println(bean);
		// 外部类
//		OuterClass outerClass = context.getBean(OuterClass.class);
//		System.out.println(outerClass);
//		System.out.println(outerClass.getOuterClass());
//		System.out.println(outerClass.getOuterClass()==outerClass);
//		User user = context.getBean(User.class);
//		System.out.println(user);
//		MyComponentScan myComponentScan = (MyComponentScan) context.getBean("myComponentScan");
//		System.out.println(myComponentScan);
//		MyComponentScan.InnerClass innerClass = context.getBean(MyComponentScan.InnerClass.class);
//		System.out.println(innerClass);
//		isConfigurationCandidate，MutablePropertyValues，ConfigurationClass
//		String content = "D010102";
//		Pattern pattern = Pattern.compile("[1-9]\\d*");
//
//		// 在文本中查找数字
//		Matcher matcher = pattern.matcher(content);
//		while (matcher.find()) {
//			System.out.println("Number found: " + matcher.group());
//		}
//
//		List<User> list = new ArrayList<>();
//		List<User> collect = list.stream().filter(x -> "123".equals(x)).collect(Collectors.toList());
//		List<String> collect1 = collect.stream().map(x -> "123").collect(Collectors.toList());
//		System.out.println(collect.size());
//		System.out.println(collect1);
	}
}
